package org.semanticflash.rdf.graph.redirection
{
	

	import com.bigflexlib.ds.container.zet.IOSet;
	import com.bigflexlib.etc.alias.AliasRecord;
	
	import flash.events.Event;
	
	import org.semanticflash.rdf.values.IRI;
	
	

	/**
	 *  
	 * Dispatched when "cannonical" changes.
	 * 
	 *  @eventType flash.events.Event.CHANGE
	 */
	[Event(name="change", type="flash.events.Event")]	
	
	
	
	/**
	 * 
	 * IRI redirection within a graph
	 * 
	 * @author aldo.bucchi@gmail.com
	 * 
	 */	
	public class IRIRedirection extends AbstractRDFRedirection
	{


		private var _iri:IRI;
		public function get iri():IRI
		{
			return _iri;
		}



		[Bindable("change")]
		public function get cannonical( ):IRI
		{
			return aliasRecord.cannonical as IRI;
		}
		
		
		
		public function get aliases( ):IOSet
		{
			return aliasRecord.aliases;
		}



		private var aliasRecord:AliasRecord;


		
		
		public function IRIRedirection( iri:IRI, context:RDFRedirectionContext )
		{
		
			super( context );

			_iri = iri;
			
			aliasRecord = context.aliasContext.getRecord( iri );
			
			aliasRecord.addEventListener( Event.CHANGE, aliasRecord_change );
		
		}
		
		
		
		private function aliasRecord_change( event:Event ):void
		{

			dispatchEvent( new Event( Event.CHANGE ) );
		
		}


		

	}
	

}





























